//package com.wanwu.channel.service.strategy.handle.allianpay;
//
//
//import com.wanwu.channel.common.util.LogUtil;
//import com.wanwu.channel.core.ClearService;
//import com.wanwu.channel.dao.entity.ChannelClearEntity;
//import com.wanwu.channel.remote.allinpay.TLHttp;
//import com.wanwu.channel.remote.allinpay.TLHttpUtils.TLRspCodx;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//
//import static com.wanwu.channel.remote.allinpay.TLHttp.*;
//
///**
// * @author JiWen
// * @time 2020/1/21 15:19
// */
//@Service("execApplyHandler")
//public class ExecApplyHandler implements Handler {
//
//    public static Logger logger = LoggerFactory.getLogger(ExecApplyHandler.class);
//    @Resource
//    private ClearService clearService;
//
//    @Override
//    public void handle(AliianPayContext context) {
//        ChannelClearEntity clearEntity = context.getClearEntity();
//        StepEnum stepEnum = StepEnum.getByCode(Integer.parseInt(clearEntity.getExt2()));
//        if (StepEnum.EXEC_APPLY != stepEnum) {
//            return;
//        }
//        try {
//            LockRateReq rateReq = toLockRateReq(clearEntity);
//            LockRateResp rateResp = (LockRateResp) TLHttp.request(BizTypeEnum.LOCK_RATE, rateReq);
//            if (TLRspCodx.REQ_SUCC.equals(rateResp.getRspcode())) {
//                ExecPayApplyReq execPayApplyReq = toExecPayApplyReq(clearEntity);
//                ExecPayApplyResp resp = (ExecPayApplyResp) TLHttp.request(BizTypeEnum.EXEC_APPLY, execPayApplyReq);
//                if (TLRspCodx.REQ_SUCC.equals(rateResp.getRspcode())) {
//                    clearEntity.setExt2(String.valueOf(StepEnum.APPLY_QUERY2.getCode()));
//                    clearService.updateChannelClear(clearEntity);
//                }
//            }
//            clearEntity.setThirdRespCode(rateResp.getRspcode());
//            clearEntity.setThirdRespMsg(rateResp.getRspinfo());
//            clearService.updateChannelClear(clearEntity);
//        } catch (Exception e) {
//            LogUtil.error(logger, e, "通联支付执行申请单异常: channelNo: {0}", clearEntity.getChannelNo());
//        }
//    }
//
//    private LockRateReq toLockRateReq(ChannelClearEntity clearEntity) {
//        LockRateReq req = new LockRateReq();
//        req.setMeraplid(clearEntity.getSerialNo());
//        req.setApplyId(clearEntity.getExt1());
//        return req;
//    }
//
//    private ExecPayApplyReq toExecPayApplyReq(ChannelClearEntity clearEntity) {
//        ExecPayApplyReq req = new ExecPayApplyReq();
//        req.setMeraplid(clearEntity.getSerialNo());
//        req.setApplyId(clearEntity.getExt1());
//        req.setExtype("LK");// 锁汇成交
//        return req;
//    }
//}
